package net.cyndeline.rldungeon.dgs.strategy.pointlessArea

import scalax.collection.immutable.Graph
import net.cyndeline.rldungeon.dgs.strategy.help.{CollapsedEdge, CollapsedNode}
import scala.util.Random
import net.cyndeline.rldungeon.dgs.graph.Room

/**
 * Examines a collapsed graph and finds pointless nodes on it that should be assigned
 * rewards/activators in order to remove all pointless areas.
 *
 * @tparam VType Type of room contained in the collapsed node.
 */
trait PointlessNodeFinder[VType <: Room[VType]] {


  /**
   * Searches for a random node that is eligible for an activator. The requirement for this is that the node appears
   * in an area connected to a node on the main path that has additional meaningful edges below it that can host the
   * activators responder.
   * @param graph The graph to find a pointless node in.
   * @param validMainAreaConnection The set of nodes along the main path in the graph that has edges below it that
   *                                can host at least one more responder.
   * @return A random pointless node, or None of no pointless nodes exist or if every pointless node has a main area
   *         connection that isn't present in the submitted set.
   */
  def findActivatorNode(graph: Graph[CollapsedNode[VType], CollapsedEdge[VType]#Inner], validMainAreaConnection: Set[CollapsedNode[VType]]): Option[CollapsedNode[VType]]

  /**
   * Searches for a random pointless node whose only requirement is that it can hold an additional reward.
   * @param graph Graph to search for the pointless node in.
   * @return A pointless node that can host one more reward, or none if no such nodes exist.
   */
  def findRewardNode(graph: Graph[CollapsedNode[VType], CollapsedEdge[VType]#Inner]): Option[CollapsedNode[VType]]

}
